<?php
class DBMJoin {
	const INNER_JOIN 	= 1;
	const LEFT_JOIN 		= 2;
	const RIGHT_JOIN		= 3;
	const OUTER_JOIN	= 4;
	
	private $entity = null;
	private $type = 1;
	private $filterGroups = array();
	
	public function __construct(DBMEntity $entity, $type = 1, $filters = array()){
		// create the basic filter group
		$this->addFilterGroup(new DBMFilterGroup(DBMFilterGroup::AND_GROUP), true);
		
		// set the entity
		$this->setEntity($entity);
		
		// set the type
		$this->setType($type);
		
		// add the filters
		foreach($filters as $filter){
			$this->addFilter($filter);
		}
	}
	
	public function getEntity(){
		return $this->entity;
	}
	public function setEntity(DBMEntity $entity){
		$this->entity = $entity;
	}
	public function getType(){
		return $this->type;
	}
	public function setType($type){
		$this->type = $type;
	}
	public function getFilterGroups(){
		return $this->filterGroups;
	}
	
	public function addFilterGroup(DBMFilterGroup $group, $primary = false){
		if($primary){
			$this->filterGroups["primary"] = $group;	
		} else {
			$this->filterGroups[] = $group;
		}
		
	}
	public function addFilter(DBMFilter $filter){
		$this->filterGroups["primary"]->addFilter($filter);
	}
}

?>